package com.yanqu.road.server.cmd.activity.dafuweng;

import com.yanqu.road.entity.activity.dafuweng.DFWUnionRecord;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.monopoly.CrossMonopolyProto;
import com.yanqu.road.pb.monopoly.MonopolyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.cross.battle.DaFuWengDataMgr;
import com.yanqu.road.server.pb.CrossDaFuWengPb;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.List;

@Cmd(code = CrossProtocol.C_CROSS_DA_FU_WENG_UNION_RECORD, desc = "")
public class CrossDfwUnionRecordCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossMonopolyProto.CrossDfwUnionRecordReqMsg reqMsg = CrossMonopolyProto.CrossDfwUnionRecordReqMsg.parseFrom(packet.getBytes());
        int activityId = reqMsg.getActivityId();
        String unionId = reqMsg.getUnionId();
        int type = reqMsg.getType();
        List<DFWUnionRecord> list = DaFuWengDataMgr.getUnionRecord(activityId, unionId, type, groupId);
        MonopolyProto.GetUnionRecordRespMsg.Builder builder = MonopolyProto.GetUnionRecordRespMsg.newBuilder();
        builder.setRet(ret);
        List<MonopolyProto.UnionRecordMsg> msgList = CrossDaFuWengPb.parseUnionRecordMsgList(list);
        builder.addAllRecordList(msgList);
        YanQuMessage message = YanQuMessageUtils.buildMessage(ClientProtocol.U_DA_FU_WENG_UNION_RECORD, builder);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), message);
    }

    @Override
    public void sendData() {

    }
}
